<?php
namespace Common\Model;
use Common\Model\BaseModel;
use Think\Model;

/**
 * Class AdminModel
 * @package Admin\Model
 * 管理员模型
 */
class AdminModel extends BaseModel {
    public $pix = "";
    public $fieldsStr = '*';
    public $orderStr = 'id asc';

    public function get_user($uid){
        $map['id'] = array('eq', $uid);
        $one = $this->where($map)->find();
        return $one ? $one : false;
    }

    public function set_user($user){
//        $user = filterInput($user);
        if(isset($user['id'])){
            return $this->save($user);
        }
        return false;
    }

    public function add_user($user){
        if(isset($user['id'])){
            $map['id'] = array('eq', $user['id']);
        }
        $map['username'] = array('eq', $user['username']);
        $one = $this->where($map)->find();
        if($one){
            return false;
        }
        return $this->add($user);
    }

    public function check_user($map){
        return $this->where($map)->find();
    }

}